<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
		[#include "/html/include/easyuicss.html" /]
		[#include "/html/include/easyuijs.html" /]
		<script type="text/javascript" src="${app }/static/js/common.utils.js"></script>
	</head>
	<body>
		[#assign xzcs=JspTaglibs['/WEB-INF/xzcs.tld'] /]
		<form id="infoForm" class="easyui-form" method="post" data-options="novalidate:true">
			<input type="hidden" name="method" value="${RequestParameters['method']}" />
			<input type="hidden" name="accountId" id="accountId" value="${RequestParameters['accountId']?default(info.account_id)}" />
			<input type="hidden" name="menuId" value="${info.menu_id}" />
			<table class="tblEidt">
				<tr>
					<td class="tdText" style="width:20%;">
						菜单名称<label style="color:red;">*</label>：
					</td>
					<td class="tdInput" style="width:80%;">
						<input class="easyui-textbox" name="menuName" value="${info.menu_name}" style="width:80%;" data-options="required:true" />
					</td>
				</tr>
				<tr>
					<td class="tdText">
						菜单key<label style="color:red;">*</label>：
					</td>
					<td class="tdInput">
						<input class="easyui-textbox" name="menuKey" value="${info.menu_key}" style="width:80%;"
							   data-options="required:true,validateOnCreate:false,validType:{remote:['${app}/weixin/menumgr/checkMenuKey.do?accountId=${RequestParameters['accountId']}&menuId=${info.menu_id}','menuKey']}" />
					</td>
				</tr>
				<tr>
					<td class="tdText">
						上级菜单<label style="color:red;">*</label>：
					</td>
					<td class="tdInput">
						[@xzcs.select id="parentId" name="parentId" value="${(info.parent_id)?default('')}" cssClass="easyui-combobox"
						style="width:80%;" otherAttr='data-options="editable:false,required:true" validType="Commbox[\'该选项为必选项\',\'#parentId\']" '
						list=Request['parents'] headLabel="根节点" headValue="-1" optionLabel="menu_name" optionValue="menu_id"]
						[/@xzcs.select]
					</td>
				</tr>
				<tr>
					<td class="tdText">
						菜单类型<label style="color:red;">*</label>：
					</td>
					<td class="tdInput">
						[@xzcs.select id="menuType" name="menuType" value="${(info.menu_type)?default('')}" cssClass="easyui-combobox"
						style="width:80%;" otherAttr='data-options="editable:false,required:true,onSelect:selectMenuType" validType="Commbox[\'该选项为必选项\',\'#menuType\']" '
						list=Request['menuType'] headLabel="请选择" headValue="" optionLabel="item_name" optionValue="item_id"]
						[/@xzcs.select]
					</td>
				</tr>
				<tr>
					<td class="tdText">
						消息类型<label style="color:red;">*</label>：
					</td>
					<td class="tdInput">
						[@xzcs.select id="msgType" name="msgType" value="${(info.msg_type)?default('')}" cssClass="easyui-combobox"
						style="width:80%;" otherAttr='data-options="editable:false,required:true,onSelect:selectMsgType" validType="Commbox[\'该选项为必选项\',\'#msgType\']" '
						list=Request['msgType'] headLabel="请选择" headValue="" optionLabel="item_name" optionValue="item_id"]
						[/@xzcs.select]
					</td>
				</tr>
				<tr>
					<td class="tdText">
						消息内容<label style="color:red;">*</label>：
					</td>
					<td class="tdInput">
						<select id="templateId" name="templateId" style="width:80%;"
								data-options="editable:false,required:true"
								validType="Commbox['该选项为必选项','#templateId']">

						</select>
					</td>
				</tr>
				<tr>
					<td class="tdText">
						菜单链接<label id="cdlj" style="color:red;display: none">*</label>：
					</td>
					<td class="tdInput">
						<input class="easyui-textbox" name="menuUrl" style="width:80%;" value="${info.menu_url}" data-options="required:true" validType="url" />
					</td>
				</tr>
				<tr>
					<td class="tdText">
						菜单顺序<label style="color:red;">*</label>：
					</td>
					<td class="tdInput">
						<input class="easyui-textbox" name="showOrder" style="width:80%;" data-options="required:true" validType="Number['顺序为数字']" value="${info.show_order}" />
					</td>
				</tr>
			</table>
			<div class="edit-btn-group">
				<a href="javascript:;" class="easyui-linkbutton"
				   data-options="iconCls:'icon-ok'" style="width:80px"
				   onclick="save(this);">保存</a>
				&nbsp;&nbsp;
				<a href="javascript:;" class="easyui-linkbutton"
				   data-options="iconCls:'icon-cancel'" style="width:80px"
				   onclick="closeWindow();">关闭</a>
			</div>
		</form>
	</body>
    <script type="text/javascript">
		var index = parent.layer.getFrameIndex(window.name);
		function closeWindow(){
			parent.layer.close(index);
		}
		function save(obj){
			$(obj).linkbutton('disable');
			$('#infoForm').form('submit', {
				url: '${app}/weixin/menumgr/save.do',
				onSubmit: function () {
					var valid = $(this).form('enableValidation').form('validate');
					if (!valid) {
						$(obj).linkbutton('enable');
					}
					return valid;
				},
				success: function (data) {
					var result = $.parseJSON(data);
					//$.messager.alert('系统提醒', result.msg);
					parent.easyui.msgShow('系统提醒', result.msg, 3000, 250, 100);
					$(obj).linkbutton('enable');
					if (result.result == 1) {
						parent.layer.close(index);
						parent.frames[parent.iframeName].window.showList();
					}
				}
			});
		}
		function selectMenuType(data){
			if (data.value == 'view') {
				$('#menuUrl').validatebox({
					required: true
				});
				$('#cdlj').show();
			} else {
				$('#menuUrl').validatebox({
					required: false
				});
				$('#cdlj').hide();
			}
			//$.parser.parse($('#menuUrl'));
		}
		function selectMsgType(data){
			var url = '${app}/weixin/autoresp/getMsgs.do?msgType='+data.value+'&accountId='+$('#accountId').val();
			$('#templateId').combobox({
				url: url,
				valueField:'id',
				textField:'template_name',
				onLoadSuccess:function() {
					var data = $(this).combobox('getData');
					$('#templateId').empty();
					$.each(data, function(i){
						$('#templateId').append('<option value="' + data[i]['id'] + '">' + data[i]['template_name'] + '</option>');
					});
					$(this).combobox('select', '${info.template_id}');
				}
			});
		}
    </script>
</html>